package com.alliky.core.loader;

import android.content.Context;

/**
 * ================================================
 *
 * @Description: 描述  Loading封装
 * @Author: wxianing
 * @Date: 2023/7/27 15:59
 * ================================================
 */
public class Loader {
    private LoaderDialog mDialog;
    private Context mContext;
    private String message = "";

    public Loader(Context context) {
        mContext = context;
    }

    public void showLoading() {
        showLoading(message);
    }

    public void showLoading(String message) {
        if (mDialog == null) {
            mDialog = new LoaderDialog(mContext, message);
        }
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        mDialog.show();
    }

    public void hideLoading() {
        if (mDialog != null) {
            mDialog.cancel();
        }
    }

    public void destory() {
        if (mDialog != null) {
            if (mDialog.isShowing()) {
                mDialog.cancel();
            }
            mDialog = null;
        }
    }
}
